<template>
  <div class="shopcart-container">
    <!-- 商品列表 -->
    <div class="goods-list">
      <!-- 商品列表项区域 -->
      <div class="card">
        <div class="card-content" v-for="(item) in order.goods" :key="item.id">
          <div class="card-content-inner ">
            <img :src="`${APIBaseURL}${item.goods_img}`" />
            <div class="info">
              <h1>{{ item.goods_name }}</h1>
              <p>
                <span class="price">¥{{ item.price }}</span>
                <span>x{{ item.count }}</span>
              </p>
            </div>
          </div>
        </div>
        <!-- 订单备注 -->
        <div class="process-info">
          <p>
            <strong>订单备注</strong>
          </p>
          <p>
            <span>{{ order.note }}</span>
          </p>
        </div>
        <!-- 配送信息 -->
        <div class="process-info">
          <p><strong>配送服务</strong></p>
          <p><span>中小件送货时间</span></p>
          <p> <strong>快递运输</strong></p>
         <p> <span>工作日、双休日与节假日均可送货</span></p>
        </div>
        <!-- 收货地址 -->
        <div class="process-info">
          <p>
            <strong>收货地址</strong>
          </p>
          <p>
            <span>{{ order.address_name }} {{ order.address_phone }}</span>
          </p>
          <p>
            <span>{{ order.address_area }} {{ order.address_detail }}</span>
          </p>
        </div>
      </div>
    </div>
    <!-- 运费信息 -->
    <ul class="fare-info ">
      <li class="fare-price ">
        <span>商品金额</span>
        <span class="red">¥{{ order.amount }}</span>
      </li>
      <li class="fare-price">
        <span>运费</span>
        <span class="red">¥0.00</span>
      </li>
      <li class="fare-price">
        <span>
          <strong>总价</strong>
        </span>
        <span class="red">¥{{ order.amount }}</span>
      </li>
      <!-- 去支付按钮 -->
      <div v-if="order.id && !order.is_cancel" >
        <mt-button size="large" @click="$toast('还未实现....')">去支付</mt-button>
      </div>
    </ul>
  </div>
</template>

<script>
import {HTTPGetOrderDetail} from "@/api/order.js"

export default {
  data () {
    return {
      order: {}
    }
  },
  props: ['id'],
  created () {
    this.getOrder()
  },
  methods: {
    async getOrder () {
      try {
        let result = await HTTPGetOrderDetail({ id: this.id });
        if (result.code === 1) {
          this.order = result.data; 
          console.log(this.order) 
        }
        else if(result.code === 2){
          this.$router.push({ name: 'login' })
        }
        else{
          throw result.msg;
        }

      } catch (error) {
        this.$messagebox("错误",error)
      }
    },//======================================= 
  }
}
</script>

<style lang="scss" scoped>
.flex {
  display: flex;
}
.shopcart-container {
  background: #eee;
  overflow: hidden;
  // 商品列表
  .goods-list {
    margin-top: 10px;
    .card {
      margin: 0;
      .card-content {
        border-bottom: 1px solid #eee;
        .card-content-inner {
          display: flex;
          align-items: center;
          padding: 10px;
          img {
            width: 60px;
          }
          .info {
            margin-left: 10px;
            box-sizing: border-box;
            width: 100%;
            overflow: hidden;
            h1 {
              font-size: 13px;
              font-weight: bold;              
              padding-top: 10px;
            }
            p .price {
                font-size: 14px;
                font-weight: 700;
                color: red;                
            }
            
          }
        }
      }
      // 订单备注 配送信息 收货地址
      .process-info {
        padding: 10px;
        border-bottom: 1px solid #eee;
        p {
          color: #333;
          span {
            color: #999;
          }
        }
      }
    }
  }
  // 运费信息
  .fare-info {
    padding: 10px;    
    .fare-price {
      padding: 5px 0;
      display: flex;
      justify-content: space-between;
      .red {
        color: red;
        font-size: 16px;
      }
    }
  }
}
</style>
